﻿Imports BUS, DTO
Public Class frmcapnhatlydothanhlysach
    Private Sub LoadLyDoThanhLySach()
        dgvDanhSachLyDoThanhLySach.Rows.Clear()
        Dim bus As New LyDoThanhLySachBUS()
        Dim dsLDTL As New List(Of LyDoThanhLySachDTO)
        dsLDTL = bus.LayDSLyDoThanhLySach()

        For i As Integer = 0 To dsLDTL.Count - 1
            dgvDanhSachLyDoThanhLySach.Rows.Add(dsLDTL(i).MaLyDoThanhLySach, dsLDTL(i).TenLyDoThanhLySach)
        Next
    End Sub

    Private Sub frmcapnhatlydothanhlysach_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        LoadLyDoThanhLySach()
    End Sub

    Private Sub SimpleButton_CapNhat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SimpleButton_CapNhat.Click
        If dgvDanhSachLyDoThanhLySach.CurrentRow.Index >= 0 Then
            Dim frm As New frmxlcapnhatlaydothanhlysach()
            frm.MaLyDo = dgvDanhSachLyDoThanhLySach.Item(0, dgvDanhSachLyDoThanhLySach.CurrentRow.Index).Value
            If frm.ShowDialog() = Windows.Forms.DialogResult.OK Then
                LoadLyDoThanhLySach()
            End If
        Else
            MessageBox.Show("Chưa chọn loại đọc giả !")
        End If
    End Sub
End Class